using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace Gltf
{

    public class ExtensibleObject
    {

        public static string TypeName = "";
        public  static string ExtensionName = "";
        /**
 * @brief The extensions attached to this object.
 *
 * Use {@link getExtension} to get the extension with a particular static
 * type. Use {@link getGenericExtension} to get unknown extensions as a
 * generic {@link CesiumUtility::JsonValue}.
 */
        public Dictionary<string, object> extensions=new Dictionary<string, object>();
        public JObject extras = new JObject();

        public T getExtension<T>() where T : ExtensibleObject
        {
            if (extensions.TryGetValue(TypeName, out object extr))
            {
                var result = extr as T;
                return result;
            }
            return null;
        }

        public static implicit operator bool(ExtensibleObject self)
        {
            return self == null ? false : true;
        }
    }
}